﻿

//设置角色
//var pId;
//var conditonId;
//var selectId;
var fnUserRoleSetting = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var pId = record.getData(const_entityID);
    //conditonId = "UserID";
    var selectId = "RoleID";
    var conditonId = "UserID='" + pId + "'";
    document.getElementById("EditUIWindow").src = "../EditWidows/YUIMenuList.aspx?pid=" + pId + "&selectid=" + selectId + "&conditonid=" + conditonId + "&masterentity=SysUserRole&masterPara=SysRole|RoleName|RoleID|True";
    YAHOO.example.container.dialog1.show();
}

//修改密码
var fnModifyPassword = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var Id = record.getData(const_entityID);
    document.getElementById("EditUIWindow").src = "../EditWidows/SysManager/UserPwdSetting.aspx?id=" + Id + "";
    YAHOO.example.container.dialog1.show();
}

var fnViewUser = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var RoleID = record.getData(const_entityID);
    //conditonId = "UserID";
    var selectId = "RoleID";
    var condition = "RoleID='" + RoleID + "'";
    document.getElementById("EditUIWindow").src = "/Extend/YUIDataTableList.aspx?entity=V_UserRole&condition=" + condition;
    YAHOO.example.container.dialog1.show();   
}


//绑定下拉框选择事件
if (typeof($)!="undefined") {
    $(document).ready(function () {
        $('#IsOutsite').get(0).selectedIndex = 1;
        if ($('#IsOutsite').children('option:selected').val() == "True") {
            var trs = $("table tr");
            for (i = 0; i < trs.length; i++) {
                if (i == 6) {
                    trs[i].style.display = "none";
                } else {
                    trs[i].style.display = "block";
                }
            }
        } else if ($('#IsOutsite').children('option:selected').val() == "False") {
            var trs = $("table tr");
            for (i = 0; i < trs.length; i++) {
                if (i == 7 || i == 8 || i == 9) {
                    trs[i].style.display = "none";
                } else {
                    trs[i].style.display = "block";
                }
            }
        }
        var btnName = "";
        $('#IsOutsite').change(function () {
            var OptionValue = $(this).children('option:selected').val();
            if (OptionValue == "True") {   //是
                var trs = $("table tr");
                for (i = 0; i < trs.length; i++) {
                    if (i == 6) {
                        trs[i].style.display = "none";
                    } else {
                        trs[i].style.display = "block";
                    }
                }
                $("#btnEmpID").attr("name", "C");
                $("#btnCustomerID").attr("name", "C");
                $("#txtEmpID").val("");
            } else if (OptionValue == "False") {  //否
                var trs = $("table tr");
                for (i = 0; i < trs.length; i++) {
                    if (i == 7 || i == 8 || i == 9) {
                        trs[i].style.display = "none";
                    } else {
                        trs[i].style.display = "block";
                    }
                }
                $("#btnCustomerID").attr("name", "E");
                $("#btnEmpID").attr("name", "E");
                $("#txtCustomerID").val("");
            }
        });
    })
}

//用户信息导入
var fnImportExcel = function () {
    document.getElementById("EditUIWindow").src = "../Account/ExcelToSql/ExcelImport.aspx";
    YAHOO.example.container.dialog1.show();
}